﻿@model Apps.Models.MIS.MIS_ArticleModel
@using Apps.Common;
@using Apps.Web.Core;
@using Apps.Models.Sys;
@using Apps.Locale;
@{
    ViewBag.Title = "文章修改";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}
<script src="~/Scripts/editor/ueditor.config.js"></script>
<script src="~/Scripts/editor/ueditor.all.min.js"></script>
<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
<script type="text/javascript">
    function setCategory() {
        $.post("/MIS/Category/GetListByParentId", { id: $("#CategoryName").val() }, function (data) {
            if (data == "") {
                $("#CategoryId").html("<option>--没有数据--</option>");
            }
            else {
                $("#CategoryId").html(data);
                $("#CategoryId").val("@Model.CategoryId");

            }
        }, "json");
    }

    $(function () {
        $("#IsType").val("@(Model.IsType)");
        $.post("/MIS/Category/GetListByParentId", { id: "@Model.CategoryIdParent" }, function (data) {
            if (data == "") {
                $("#CategoryId").html("<option>--没有数据--</option>");
            }
            else {
                $("#CategoryId").html(data);
                $("#CategoryId").val("@Model.CategoryId");

            }
        }, "json");
        //加载编辑器
        var ue = UE.getEditor('BodyContent', {
            toolbars: [[
                    'fullscreen', 'source',
                    'bold', 'italic', 'underline', 'forecolor', 'insertorderedlist',
                   'fontfamily', 'fontsize',
                    'justifyleft', 'justifycenter',
                    'link', 'unlink',
                    'simpleupload', 'snapscreen'


            ]],
            serverUrl: "/Core/controller.ashx"
        });

        $("#CategoryName").change(function () {
            setCategory();
        });

        $("#btnSave").click(function () {
            if (!$("form").valid()) {
                window.parent.messageBox10s('提示', $("#ErrMesList").html());
                return;
            }
            $.ajax({
                url: "/MyArticle/Edit",
                type: "Post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.type == 1) {
                        window.parent.frameReturnByMes(data.message);
                        window.parent.frameReturnByReload(true);
                        window.parent.frameReturnByClose()
                    }
                    else {
                        window.parent.frameReturnByMes(data.message);
                    }
                }
            });
        });
        $("#btnReturn").click(function () {
            window.parent.frameReturnByClose();
        });
        //init
        $("#CategoryName").val('@Model.CategoryId');
        $("#CategoryName").val("@Model.CategoryIdParent");
    });
</script>

@using (Html.BeginForm())
{
    <div id="ErrMesList">
        <div id="ErrMesListContent">
            @Html.ValidationSummary(false)
        </div>
    </div>
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.Creater)
    @Html.HiddenFor(model => model.CreateTime)
    <table class="formtable">
        <tbody>
            <tr>
                <th>
                    @Html.LabelFor(model => model.CategoryId)：
                </th>
                <td>
                    @Html.DropDownListFor(model => model.CategoryName, ViewBag.Category as SelectList)
                    <select id="CategoryId" name="CategoryId"></select>
                </td>
                <td rowspan="6" valign="top">

                    @Html.HiddenFor(model => model.ImgUrl)
                    <img class="expic" style="width:100px; height:100px;" src="@(string.IsNullOrEmpty(Model.ImgUrl)?"/Content/Images/NotPic.jpg":Model.ImgUrl)" /><br />
                    <input class="displaynone" type="file" value="" id="FileUpload" name="FileUpload" onchange="Upload('SingleFile', 'ImgUrl', 'FileUpload','1','1');" />
                    <a href="javascript:$('#FileUpload').trigger('click').void(0);" class="files">@Resource.Browse</a><span class="uploading">@Resource.Uploading</span>

                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Title)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Title)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Sort)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Sort)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Click)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Click)
                </td>
            </tr>
            <tr>
                <td colspan="3" style="padding:10px;">
                    @Html.TextAreaFor(model => model.BodyContent, new { style = "width:675px;height:200px;" })
                </td>
            </tr>
            @*<tr>
                         <td>
                             @Html.LabelFor(model => model.CustomLink)：
                         </td>
                  <td>
                        @Html.EditorFor(model => model.CustomLink)
                    </td>
                </tr>*@
            <tr>
                <th>
                    文章类型：
                </th>
                <td>
                    <select id="IsType" name="IsType">
                        <option value="0">普通</option>
                        <option value="1">幻灯片</option>
                        <option value="2">首页栏目</option>
                    </select>
                </td>
            </tr>
        </tbody>
    </table>

}
